/*
ID: simplyz2
LANG: C
TASK: packrec
*/
#include<stdio.h>
#include<stdbool.h>
#include<stdlib.h>
#include<string.h>
#define MAX_NUM 5
#define INF 0x7FFFFFFF
#define Max(a, b) ((a)>(b) ? (a) : (b))
struct Rec {
	int h, w;
} rectangle[MAX_NUM], rect[MAX_NUM], ans[MAX_NUM];
bool used[MAX_NUM];
int w, h, total, area;

void
exchange(struct Rec *r)
{
	int temp = r->h;
	r->h = r->w;
	r->w = temp;
}

void
judge()
{
	int i, j, temp;
	if(w > h) {
		temp = w;
		w = h;
		h = temp;
	}
	if(w*h <= area) {
		if(w*h == area) {
			for(i=1; i<total; i++)
				if(ans[i].w == w)
					return;
			for(i=1; i<total; i++)
				if(ans[i].w > w) {
					for(j=total; j>i; j--)
						ans[j] = ans[j-1];
					ans[i].w = w;
					ans[i].h = h;
					++total;
					return;
				}
			ans[total].w = w;
			ans[total++].h = h;
		} else {
			area = w*h;
			total = 1;
			ans[total].w = w;
			ans[total].h = h;
		}
	}
}

void
work()
{   
	//Case 1
    w=rect[1].w+rect[2].w+rect[3].w+rect[4].w;
    h=Max(rect[1].h,rect[2].h);
    h=Max(h,rect[3].h);
    h=Max(h,rect[4].h);
    judge();
 
    //Case 2
    w=Max(rect[1].w+rect[2].w+rect[3].w,rect[4].w);
    h=Max(rect[1].h,rect[2].h);
    h=Max(h,rect[3].h);
    h+=rect[4].h;
    judge();
 
    //Case 3
    w=Max(rect[1].w+rect[2].w,rect[3].w)+rect[4].w;
    h=Max(Max(rect[1].h,rect[2].h)+rect[3].h,rect[4].h);
    judge();
 
    //Case 4
    w=rect[1].w+Max(rect[2].w,rect[3].w)+rect[4].w;
    h=Max(rect[1].h,rect[4].h);
    h=Max(h,rect[2].h+rect[3].h);
    judge();
 
    //Case 6
    if (rect[3].h>=rect[2].h+rect[4].h)
    {
        w=Max(rect[3].w+rect[2].w,rect[3].w+rect[4].w);
        w=Max(w,rect[1].w);
        h=rect[1].h+rect[3].h;
        judge();
        return;
    }
    if (rect[3].h>rect[4].h)
    {
        w=Max(rect[1].w+rect[2].w,rect[2].w+rect[3].w);
        w=Max(w,rect[4].w+rect[3].w); 
        h=Max(rect[1].h+rect[3].h,rect[2].h+rect[4].h);
        judge();
        return;
    }
    if (rect[3].h==rect[4].h)
    {
        w=Max(rect[1].w+rect[2].w,rect[3].w+rect[4].w);
        h=Max(rect[1].h,rect[2].h)+rect[3].h;
        judge();
        return;
    }
    if (rect[3].h<rect[4].h && rect[4].h<rect[3].h+rect[1].h)
    {
        w=Max(rect[1].w+rect[2].w,rect[1].w+rect[4].w);
        w=Max(w,rect[3].w+rect[4].w);
        h=Max(rect[1].h+rect[3].h,rect[2].h+rect[4].h);
        judge();
        return;
    }
    w=Max(rect[2].w,rect[1].w+rect[4].w);
    w=Max(w,rect[3].w+rect[4].w);
    h=rect[4].h+rect[2].h;
    judge(); 
}

void
rotate(int depth)
{
	if(depth == MAX_NUM) {
		work();
		return;
	}
	rotate(depth+1);
	exchange(rect+depth);
	rotate(depth+1);
}

void
dfs(int depth)
{
	int i;
	if(depth == MAX_NUM) {
		rotate(1);
		return;
	}
	for(i=1; i<MAX_NUM; i++) {
		if(!used[i]) {
			used[i] = true;
			rect[depth] = rectangle[i];
			dfs(depth+1);
			used[i] = false;
		}
	}
}

int
main(int argc, char **argv)
{
	int i;
	freopen("packrec.in", "r", stdin);
	freopen("packrec.out", "w", stdout);
	for(i=1; i<MAX_NUM; i++)
		scanf("%d %d", &rectangle[i].w, &rectangle[i].h);
	total = 1;
	area = INF;
	memset(used, 0, sizeof(used));
	dfs(1);
	printf("%d\n", area);
	for(i=1; i<total; i++)
		printf("%d %d\n", ans[i].w, ans[i].h);
	return 0;
}
